package 并发编程18.多线程start;

/**
 * @author idea
 * @data 2019/2/24
 */
public class Demo {

    static class t1 implements Runnable{

        @Override
        public void run() {
            try {
                System.out.println(Thread.currentThread().getName()+1);
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName()+1);
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName()+1);
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName()+1);
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName()+1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }


    static class t2 implements Runnable{

        @Override
        public void run() {
            try {
                System.out.println(Thread.currentThread().getName()+1);
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName()+1);
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName()+1);
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName()+1);
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName()+1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        Thread thread=new Thread(new t1());
        Thread thread2=new Thread(new t2());
        thread.start();
        thread2.start();
    }

}
